package com.online.teaching.module.common.resource.controller;

import com.online.teaching.module.common.resource.domain.vo.GetDirectoryVO;
import com.online.teaching.module.common.resource.service.CommonResourceService;
import com.online.teaching.utils.Result;
import com.online.teaching.utils.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName : CommonResourceController  //类名
 * @Description :   //描述
 * @Author : YG  //作者
 * @Date: 2020-11-26 18:04  //时间
 */
@Api(tags ="课件资源模块")
@RestController
public class CommonResourceController {

    @Autowired
    private CommonResourceService commonResourceService;

    @ApiOperation(value = "获取文件目录树", notes = "获取文件目录树")
    @PostMapping("common/resource/getDirectoryTree")
    public Result getDirectoryTree(@RequestParam("teachesId")Integer teachesId)
    {
        List<Object> directoryTree = commonResourceService.getDirectoryTree(teachesId);
        return new Result(true, StatusCode.OK,"查询成功",directoryTree);
    }

    @ApiOperation(value = "老师点击目录获取文件", notes = "老师点击目录获取文件")
    @PostMapping("common/resource/getFile")
    public Result getFile(@ApiParam("fileId") @RequestParam("fileId")Integer fileId)
    {
        return new Result(true,StatusCode.OK,"查询成功",commonResourceService.getFileList(fileId));
    }

}
